package com.example.devices.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.device.R
import com.example.devices.entity.Devices

class DevicesAdapter:BaseQuickAdapter<Devices,BaseViewHolder>(R.layout.item_devices) {
    override fun convert(holder: BaseViewHolder, item: Devices) {
        val type = holder.getView<TextView>(R.id.tv_type)
        val address = holder.getView<TextView>(R.id.tv_address)
        val lv = holder.getView<TextView>(R.id.tv_lv)
        val status = holder.getView<TextView>(R.id.tv_status)
        type.text = "设备类别: ${item.deviceName}"
        address.text = "安装地点: ${item.installationLocation}"
        lv.text = "故障率: ${item.failureRate*100}%"
        status.text = item.status
        if(item.status == "正常"){
            status.setBackgroundResource(com.example.resource.R.drawable.bg_item_devices_blue)
        }else{
            status.setBackgroundResource(com.example.resource.R.drawable.bg_item_devices)
        }
    }
}